package com.imut.oa.controller.admin;

import com.imut.oa.common.BaseResponse;
import com.imut.oa.common.PageResult;
import com.imut.oa.common.ResultUtils;
import com.imut.oa.pojo.dto.EmployeePageQueryDTO;
import com.imut.oa.pojo.dto.LeavePageQueryDTO;
import com.imut.oa.pojo.dto.UpdateLeaveStatusDTO;
import com.imut.oa.service.LeaveService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/leave")
@Slf4j
@Tag(name = "请假管理")
public class LeaveController {
    @Autowired
    private LeaveService leaveService;
    @GetMapping("/page")
    @Operation(summary = "请假分页查询")
    public BaseResponse<PageResult> page (LeavePageQueryDTO leavePageQueryDTO){
        log.info("员工分页查询：{}",leavePageQueryDTO);
        PageResult pageResult = leaveService.getLeavePage(leavePageQueryDTO);
        return ResultUtils.success(pageResult);
    }
    @PutMapping("/status")
    @Operation(summary = "请假状态修改")
    public BaseResponse<String> updateStatus(@RequestBody UpdateLeaveStatusDTO updateLeaveStatusDTO){
        log.info("请假状态用户：{}",updateLeaveStatusDTO.getId());
        leaveService.updateStatus(updateLeaveStatusDTO);
        return ResultUtils.success("修改成功","修改成功");
    }

}
